<?php
namespace app\talbum\model;
use app\base\model\BaseModel;
use think\Db;
use think\facade\Log;
/**
 * 
 */
class VideoModel extends BaseModel
{

	//get_count获得评论和点赞数和图片地址
	public function get_count($data)
	{
		$res = Db::name('video_album')->alias('p')->field('p.video,p.videoid,(select count(*) from xj_video_album_picmsg as c where c.videoid = p.videoid) as comments,(select count(*) from xj_video_album_point as po where po.videoid = p.videoid) as points')->where('p.videoid',$data['videoid'])->find();
		return $res;
	}
	//评论列表
	public function comment_list($data,$page=1,$limit=10){
		if(empty($data['limit'])) $limit=10;
			if(empty($data['page'])||$data['page']<=0) $page=1;
			$limit = $data['limit'];
			 $pre = ($page-1)*$limit;
			$res=Db::name('video_album_picmsg')->alias('pm')->field('pm.cmsgid,pm.content,pm.createtime,u.wxnickname as name,r.wxnickname as replayname,u.UserImg as userimg,r.UserImg as replayimg')->join('userinfo u','u.Userid=pm.Userid','left')->join('userinfo r','pm.Replayid=r.Userid','left')->where('pm.videoid',$data['videoid'])->order('pm.createtime','desc')->limit($pre,$limit)->select();
			return $res;
		
	
	}
	//增加时光评论
	public function comment($data){
		$res = $this->insert('video_album_picmsg',$data);
		return $res;
	}

}